#include <STC15F2K60S2.H>
#include "Relay.h"
#include "Delay.h"

sbit Key_4 = P3^0;
sbit Key_3 = P3^1;
sbit Key_2 = P3^2;
sbit Key_1 = P3^3;

static unsigned char K_Number;

/**********************************************************************/
//按键号码传送函数
/**
	* @brief  
	* @param  无
	* @retval  返回按键按下后相应的按键号
	*/
/**********************************************************************/
unsigned Key_return(void)
{
	unsigned char keynumber = K_Number;
	K_Number = 0;
	return keynumber;
}
/**********************************************************************/
//获取按键号函数
/**********************************************************************/
unsigned char Key()
{
	 unsigned char Key_Nunber = 0;
	if(Key_1 == 0){Key_Nunber = 1;}
	if(Key_2 == 0){Key_Nunber = 2;}
	if(Key_3 == 0){Key_Nunber = 3;}
	if(Key_4 == 0){Key_Nunber = 4;}
	return Key_Nunber;
}
/**********************************************************************/
//按键循环扫描函数
/**********************************************************************/
void Key_Loop(void)
{
	static unsigned char Now,Last;
	Last = Now;
	Now = Key();
	if(!Now && Last)
	{
		K_Number = Last;
	}
}

/**********************************************************************/



